﻿using System.Collections.Generic;
using Yamfinder.Service;

namespace Yamfinder.Web.Models
{
    public class ImportMappingModel
    {
        public ImportMappingModel() { }

        public ImportMappingModel(AnalysedImportColumn column, IList<string> dataDictonaryEntries)
        {

            ImportName = column.Name;
            Type = column.Type;
            ExistingFields = dataDictonaryEntries;

            DatabaseName = ImportName;
            IntialActionText = "Create a new field - '" + ImportName + "'";

            foreach (var field in ExistingFields)
            {
                if (field.ToLowerInvariant() == ImportName.ToLowerInvariant())
                {
                    DatabaseName = field;
                    IntialActionText = "Map to existing database field - '" + DatabaseName + "'";
                    break;
                }
            }
        }

        public string ImportName { get; set; }
        public string Type { get; set; }

        public string IntialActionText { get; set; }

        public string DatabaseName { get; set; }

        public IList<string> ExistingFields { get; set; }
    }
}